{% extends 'inventory/base.html' %}
{% load widget_tweaks %}

{% block content %}
<div class="container mt-4">
    <div class="row justify-content-center">
        <div class="col-md-8">
            <div class="card">
                <div class="card-header">
                    {% if form.instance.id %}
                        <h4 class="mb-0">编辑会员信息</h4>
                    {% else %}
                        <h4 class="mb-0">添加新会员</h4>
                    {% endif %}
                </div>
                <div class="card-body">
                    <form method="post">
                        {% csrf_token %}
                        {% for field in form %}
                            <div class="mb-3">
                                <label for="{{ field.id_for_label }}" class="form-label">{{ field.label }}</label>
                                {{ field.errors }}
                                {{ field|add_class:"form-control" }}
                                {% if field.help_text %}
                                    <div class="form-text">{{ field.help_text }}</div>
                                {% endif %}
                            </div>
                        {% endfor %}
                        <div class="d-grid gap-2">
                            <button type="submit" class="btn btn-primary">保存</button>
                            <a href="{% url 'member_list' %}" class="btn btn-secondary">返回列表</a>
                        </div>
                    </form>
                </div>
            </div>
        </div>
    </div>
</div>
{% endblock %}